package net.kangyee.eventmanager.commands;

import org.bukkit.entity.Player;

import net.kangyee.eventmanager.EventManager;
import net.kangyee.eventmanager.util.ConfigManager;
import net.kangyee.eventmanager.util.MessageManager;

public class CmdCreate extends EventManagerCommand {
	
	private EventManager plugin;
	private ConfigManager config;
	
	public CmdCreate(EventManager plugin, ConfigManager config){
		this.plugin = plugin;
		this.config = config;
	}
	
	public void onCommand(Player player, String[] args){
		if(args[2].equalsIgnoreCase("T") || args[2].equalsIgnoreCase("True")){
			if(args.length == 3){
				MessageManager.sendNormalMessageToAll(config.messageCreate.replaceAll("%event%", args[1]));
			}
			else {
				MessageManager.sendNormalMessageToAll(args[3]);
			}
			onEventCreate(args[1]);
		}
		else{
			onEventCreate(args[1]);
		}
		return;
	}
	
	private void onEventCreate(String name){
		plugin.setEventState(true);
		plugin.setEventName(name);
		plugin.setEventRegState(true);
	}

	public String getCmdName(){
		return "create";
	}

	public String getArgs(){
		return "<活动名称> <T(rue)/F(alse)> [全服消息内容]";
	}
	
	public int getMaxArgs(){
		return 4;
	}
	
	public int getMinArgs(){
		return 3;
	}

	public String getPermission(){
		return "eventmanager.admin." + getCmdName();
	}
	
	public boolean getStateRequire(){
		return false;
	}
	
	public boolean getRegPCRequire() {
		return false;
	}
}
